<?php  
/* OpenBIBLIO -- A library administration web interface
 * Copyright (C) 2011-     Laurent Luyssen   <big.lol13@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ 
include_once("includes/db.inc");
include_once("includes/functions.inc");
session_start();
include_once("includes/session.inc");

ControleAcces("pret_out.php", null, null,$user_id, session_id());
if(!$user_id)
{
 exit;
}

include ("includes/header.inc");
$id = $_GET['id'];

if (!isset($id) || ($id < 0))
{
   echo "<center><H2>";
   echo _("Veuillez choisir un livre !");
   echo "</H2></center>";
} 
else {
	// Check if book is already borrowed
	$b = get_borrower($id);
	if (!$b) {
	   echo "<center><H2>";
	   echo _("Ce livre n'est pas emprunt&eacute;");
	   echo "</H2></center>";
	}
	else {
		$date_in = date("Y-m-d");
		$request = "UPDATE prets2 SET date_in =\"$date_in\" WHERE id=".$b['id'];
		$resultat = biblio_db_query($request);
		if (!resultat) {
			print "PROBLEME : " .biblio_db_error();
        }
        else {
        	echo "<center><img src=\"images/in.png\"><BR/>";
        	echo "<H2><A HREF=\"javascript:self.close();\">OK</A></H2></center>";
        }
	}
}
?>
   <br><br>
   <div>
   <span id=left-text>
   <A HREF="javascript:self.close();">
   <?php echo _("Fermer"); ?>
   </A></span>
   </div>
   <br>
   <?php
   include("includes/footer.inc");
   exit;

?>
